Swift Script
2015-07-07
Kommentare
今天在 FB 湊巧看到有人 PO Swift Script 這篇。
稍微玩了一下~~。
使用 Swift Script
方法1
xcrun swift hello.swift
方法2
chmod +x hello.swift
1 | #!/usr/bin/env xcrun swift |
./hello.swift
搭配 Carthage
1 | github "jdhealy/PrettyColors" |
carthage update
swift hello.swift -F FRAMEWORK_LOACTION
其他 Swift CLI Framework
當天 Talk Repo
Swift for CLI tools
介紹蠻仔細的簡報
Compile & run
1 | swiftc hello.swift -o hello |
Caveats
arg
Process.arguments
Status Code
exit(0) // 0
Option parsing
IO
Spawning
git status | slug | say
Reading / Writing
1 | import IO |
File
1 | File.join(Dir.home. "code") // ~/code |
File Structure
1 | └── slug |
Test
swift test